package com.mz.ozy.mvp.presenter;


import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.LotteryBean;
import com.mz.ozy.bean.LotteryStateBean;
import com.mz.ozy.mvp.model.LotteryModel;
import com.mz.ozy.mvp.view.LotteryContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class LotteryPresenter extends BasePresenterImpl<LotteryContract.View> implements LotteryContract.Presenter {

    private LotteryModel mModel;

    public LotteryPresenter() {
        mModel = new LotteryModel();
    }


    @Override
    public void getLotteryState(Activity activity) {
        mModel.getLotteryState(activity)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<LotteryStateBean>(mView, false) {
                    @Override
                    public void onSuccesss(LotteryStateBean bean) {
                        mView.getLotteryStateSuccess(bean);
                    }
                });
    }

    public void onLottery(Context context) {
        mModel.onLottery(context)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<LotteryBean>(mView, false) {
                    @Override
                    public void onSuccesss(LotteryBean bean) {
                        mView.onLotterySuccess(bean);
                    }
                });
    }
}
